home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / mac / DirectX SDK / DXSDK / samples / Multimedia / Direct3D / SkinnedMesh / skinmesh2.vsh < prev    next >
Text File  |  2001-10-08  |  2KB  |  86 lines

  1.  
  2. vs.1.1
  3.  
  4. ;------------------------------------------------------------------------------
  5. ; v0 = position
  6. ; v1 = blend weights
  7. ; v2 = blend indices
  8. ; v3 = normal
  9. ; v4 = texture coordinates
  10. ;------------------------------------------------------------------------------
  11.  
  12. ;------------------------------------------------------------------------------
  13. ; r0.w = Last blend weight
  14. ; r1 = Blend indices
  15. ; r2 = Temp position
  16. ; r3 = Temp normal
  17. ; r4 = Blended position in camera space
  18. ; r5 = Blended normal in camera space
  19. ;------------------------------------------------------------------------------
  20.  
  21. ;------------------------------------------------------------------------------
  22. ; Constants specified by the app;
  23. ;
  24. ; c9-c95 = world-view matrix palette
  25. ; c8      = diffuse * light.diffuse
  26. ; c7      = ambient color
  27. ; c2-c5   = projection matrix
  28. ; c1      = light direction
  29. ; c0      = {1, power, 0, 1020.01};
  30. ;------------------------------------------------------------------------------
  31.  
  32. ;------------------------------------------------------------------------------
  33. ; oPos      = Output position
  34. ; oD0      = Diffuse
  35. ; oD1      = Specular
  36. ; oT0      = texture coordinates
  37. ;------------------------------------------------------------------------------
  38.  
  39. // Compensate for lack of UBYTE4 on Geforce3
  40. mul r1,v2.zyxw,c0.wwww
  41. //mul r1,v2,c0.wwww
  42.  
  43.  
  44. //first compute the last blending weight
  45. dp3 r0.w,v1.xyz,c0.xzz; 
  46. add r0.w,-r0.w,c0.x
  47.  
  48. //Set 1
  49. mov a0.x,r1.x
  50. m4x3 r4,v0,c[a0.x + 9];
  51. m3x3 r5,v3,c[a0.x + 9]; 
  52.  
  53. //blend them
  54. mul r4,r4,v1.xxxx
  55. mul r5,r5,v1.xxxx
  56.  
  57. //Set 2
  58. mov a0.x,r1.y
  59. m4x3 r2,v0,c[a0.x + 9];
  60. m3x3 r3,v3,c[a0.x + 9];
  61.  
  62. //add them in
  63. mad r4,r2,r0.wwww,r4;
  64. mad r5,r3,r0.wwww,r5;
  65.  
  66. //compute position
  67. mov r4.w,c0.x
  68. m4x4 oPos,r4,c2
  69.  
  70. // normalize normals
  71. dp3 r5.w, r5, r5;
  72. rsq r5.w, r5.w;
  73. mul r5, r5, r5.w;
  74.  
  75. ; Do the lighting calculation
  76. dp3 r1.x, r5, c1      ; normal dot light
  77. lit r1, r1
  78. mul r0, r1.y, c8      ; Multiply with diffuse
  79. add r0, r0, c7        ; Add in ambient
  80. min oD0, r0, c0.x     ; clamp if > 1
  81. mov oD1, c0.zzzz      ; output specular
  82.  
  83. ; Copy texture coordinate
  84. mov oT0, v4
  85.  
  86.